package ar.edu.utn.frsf.cidisi.upcolbpip.edit.tools;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.EMFEditPlugin;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.ComposedImage;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;

public class CustomItemProviderAdapter extends ItemProviderAdapter{

	public CustomItemProviderAdapter(AdapterFactory adapterFactory) {
		super(adapterFactory);
		// TODO Auto-generated constructor stub
	}
	

	@Override
	public void fireNotifyChanged(Notification notification)
	{
		
	  if (changeNotifier != null)
	  {
	      changeNotifier.fireNotifyChanged(notification);
	  }

	  if (adapterFactory instanceof IChangeNotifier)
	  {
		  CustomDiagnostic customDiagnostic = new CustomDiagnostic(notification.getNotifier());
	      IChangeNotifier changeNotifier = (IChangeNotifier)adapterFactory;
	      changeNotifier.fireNotifyChanged(notification);
	  }
	}
	
	
	@Override
	public Object getImage(Object object) {
		return overlayImage(object, getResourceLocator().getImage("full/obj16/And"));
	}
	
	
	@Override
	protected Object overlayImage(Object object, Object image)
	{
	    if (AdapterFactoryEditingDomain.isControlled(object))
	    {
	      List<Object> images = new ArrayList<Object>(2);
	      images.add(image);
	      images.add(EMFEditPlugin.INSTANCE.getImage("full/ovr16/ControlledObject"));
	      image = new ComposedImage(images);
	    }
	    return image;
	}

}
